package zb.fix.client.data;

import quickfix.Message;
import quickfix.field.MDEntryType;
import quickfix.field.MDReqID;
import quickfix.field.MDUpdateType;
import quickfix.field.MarketDepth;
import quickfix.field.SubscriptionRequestType;
import quickfix.field.Symbol;

public class MarketRequest {
	
	
	public static Message createOrderBook() {
		quickfix.fix44.MarketDataRequest orderBookRequest = new quickfix.fix44.MarketDataRequest();
		quickfix.fix44.MarketDataRequest.NoRelatedSym noRelatedSym = new quickfix.fix44.MarketDataRequest.NoRelatedSym();
		noRelatedSym.set(new Symbol("BTC/CNY"));
		orderBookRequest.addGroup(noRelatedSym);

		orderBookRequest.set(new MDReqID("123"));
		orderBookRequest.set(new SubscriptionRequestType('1'));
		orderBookRequest.set(new MDUpdateType(1));// 0全部 。1增量
		orderBookRequest.set(new MarketDepth(0));

		quickfix.fix44.MarketDataRequest.NoMDEntryTypes group1 = new quickfix.fix44.MarketDataRequest.NoMDEntryTypes();
		group1.set(new MDEntryType('0'));
		orderBookRequest.addGroup(group1);

		quickfix.fix44.MarketDataRequest.NoMDEntryTypes group2 = new quickfix.fix44.MarketDataRequest.NoMDEntryTypes();
		group2.set(new MDEntryType('1'));
		orderBookRequest.addGroup(group2);

		return orderBookRequest;
	}
	
	public static Message createTrades() {
		quickfix.fix44.MarketDataRequest liveTradesRequest = new quickfix.fix44.MarketDataRequest();
		quickfix.fix44.MarketDataRequest.NoRelatedSym noRelatedSym = new quickfix.fix44.MarketDataRequest.NoRelatedSym();
		
		// noRelatedSym.set(new Symbol("LTC/USD"));
		noRelatedSym.set(new Symbol("LTC/CNY"));
		liveTradesRequest.addGroup(noRelatedSym);
		liveTradesRequest.set(new MDReqID("123"));
		liveTradesRequest.set(new SubscriptionRequestType('1'));
		liveTradesRequest.set(new MarketDepth(0));
		quickfix.fix44.MarketDataRequest.NoMDEntryTypes group = new quickfix.fix44.MarketDataRequest.NoMDEntryTypes();
		group.set(new MDEntryType('2'));
		liveTradesRequest.addGroup(group);
		return liveTradesRequest;
	}
}
